<template>
  <!-- 数据上报 -->
  <div>
    <div v-if="this.dateList.audit === '1'">
      <h1>审核结果汇总</h1>
      <el-table :data="sumTableData" stripe border style="width: 100%">
        <el-table-column prop="error" label="问题所在" align="center" width="900"></el-table-column>
        <el-table-column prop="ls" label="例数" align="center" width></el-table-column>
        <el-table-column prop="zb" label="%" align="center" width="140"></el-table-column>
        <el-table-column prop="zt" label="类型" align="center" width></el-table-column>
      </el-table>
    </div>
    <div v-if="this.dateList.audit === '2'">
      <h1>审核结果</h1>
      <el-table :data="tableData" stripe border style="width: 100%">
        <el-table-column prop="dm" label="病案号" align="center" width></el-table-column>
        <el-table-column prop="error" label="问题所在" align="center" width="900"></el-table-column>
        <el-table-column prop="zt" label="类型" align="center" width></el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { selectResultSum, zyShangbao } from "@/api";
import { showOkMsg, showErrorMsg } from "@/utils/index.js";

export default {
  data() {
    return {
      sumTableData: [],
      tableData: [],
      url: ""
    };
  },
  props: ["dateList"],
  methods: {
    getTableList() {
      if (
        (this.dateList.dateBegin && this.dateList.dateEnd) ||
        (this.dateList.year && this.dateList.month)
      ) {
        this.$emit("fun", this.url, true);
        selectResultSum({
          endTime: this.dateList.dateEnd,
          startTime: this.dateList.dateBegin,
          sq: this.dateList.year + this.dateList.month
        })
          .then(res => {
            if (res.code === 0) {
              this.getUrl(res);
            }
          })
          .catch(err => {
            this.$emit("fun", this.url, false);
          });
      } else {
        showErrorMsg("请选择日期");
      }
    },
    getUrl(resObj) {
      zyShangbao({
        endTime: this.dateList.dateEnd,
        startTime: this.dateList.dateBegin,
        sq: this.dateList.year + this.dateList.month
      })
        .then(res => {
          if (res.code === 0) {
            this.sumTableData = resObj.data.ResultSum;
            this.tableData = resObj.data.ResultSumDetails;
            this.url = res.data;
            this.$emit("fun", this.url, false);
            showOkMsg(res.msg);
          } else {
            this.$emit("fun", this.url, false);
          }
        })
        .catch(err => {
          this.$emit("fun", this.url, false);
        });
    }
  }
};
</script>

<style scoped>
h1 {
  font-size: 24px;
  text-align: center;
  padding: 23px 0;
}
h3 {
  text-align: center;
  padding-bottom: 20px;
}
h2 {
  padding: 4px 0;
  display: flex;
  justify-content: space-between;
}
</style>